

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>在 FreeBSD 上手动部署 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="Cephadm" href="../../cephadm/" />
    <link rel="prev" title="手动部署" href="../manual-deployment/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">安装 Ceph</a></li>
          <li class="breadcrumb-item"><a href="../index_manual/">安装（手动）</a></li>
      <li class="breadcrumb-item active">在 FreeBSD 上手动部署</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/install/manual-freebsd-deployment.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">安装 Ceph</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#id1">建议的方法</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id2">其他方法</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="../index_manual/">安装（手动）</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id2">获取软件</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id3">安装软件</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../index_manual/#id4">手动部署一套集群</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index_manual/#id5">升级软件</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#windows">Windows</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="freebsd">
<h1>在 FreeBSD 上手动部署<a class="headerlink" href="#freebsd" title="Permalink to this heading"></a></h1>
<p>This a largely a copy of the regular Manual Deployment with FreeBSD specifics.
The difference lies in two parts: The underlying diskformat, and the way to use
the tools.</p>
<p>All Ceph clusters require at least one monitor, and at least as many OSDs as
copies of an object stored on the cluster.  Bootstrapping the initial monitor(s)
is the first step in deploying a Ceph Storage Cluster. Monitor deployment also
sets important criteria for the entire cluster, such as the number of replicas
for pools, the number of placement groups per OSD, the heartbeat intervals,
whether authentication is required, etc. Most of these values are set by
default, so it’s useful to know about them when setting up your cluster for
production.</p>
<p>We will set up a cluster with <code class="docutils literal notranslate"><span class="pre">node1</span></code> as  the monitor node, and <code class="docutils literal notranslate"><span class="pre">node2</span></code> and
<code class="docutils literal notranslate"><span class="pre">node3</span></code> for OSD nodes.</p>
<p class="ditaa">
<img src="../../_images/ditaa-6ac272708136ab2d2b4914b63df40635e6ef4cd5.png"/>
</p>
<section id="id1">
<h2>FreeBSD 上的磁盘布局<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p>当前的实现支持 ZFS 存储池。</p>
<ul>
<li><p>所有 Ceph 数据都会在 /var/lib/ceph 内</p></li>
<li><p>日志文件放入 /var/log/ceph</p></li>
<li><p>PID 文件放入 /var/log/run</p></li>
<li><p>每个 OSD 给分配一个 ZFS 存储池，如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">gpart</span> <span class="n">create</span> <span class="o">-</span><span class="n">s</span> <span class="n">GPT</span> <span class="n">ada1</span>
<span class="n">gpart</span> <span class="n">add</span> <span class="o">-</span><span class="n">t</span> <span class="n">freebsd</span><span class="o">-</span><span class="n">zfs</span> <span class="o">-</span><span class="n">l</span> <span class="n">osd</span><span class="mf">.1</span> <span class="n">ada1</span>
<span class="n">zpool</span> <span class="n">create</span> <span class="o">-</span><span class="n">m</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">/</span><span class="n">osd</span><span class="mf">.1</span> <span class="n">osd</span><span class="mf">.1</span> <span class="n">gpt</span><span class="o">/</span><span class="n">osd</span><span class="mf">.1</span>
</pre></div>
</div>
</li>
<li><p>可以捆绑一些缓存和日志（ ZIL ）。
但要注意，这个和 Ceph 的日志不同。缓存和日志对 Ceph 来说完全透明，
但是有利于文件系统一致性和性能。假设 ada2 是个 SSD:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">gpart</span> <span class="n">create</span> <span class="o">-</span><span class="n">s</span> <span class="n">GPT</span> <span class="n">ada2</span>
<span class="n">gpart</span> <span class="n">add</span> <span class="o">-</span><span class="n">t</span> <span class="n">freebsd</span><span class="o">-</span><span class="n">zfs</span> <span class="o">-</span><span class="n">l</span> <span class="n">osd</span><span class="mf">.1</span><span class="o">-</span><span class="n">log</span> <span class="o">-</span><span class="n">s</span> <span class="mi">1</span><span class="n">G</span> <span class="n">ada2</span>
<span class="n">zpool</span> <span class="n">add</span> <span class="n">osd</span><span class="mf">.1</span> <span class="n">log</span> <span class="n">gpt</span><span class="o">/</span><span class="n">osd</span><span class="mf">.1</span><span class="o">-</span><span class="n">log</span>
<span class="n">gpart</span> <span class="n">add</span> <span class="o">-</span><span class="n">t</span> <span class="n">freebsd</span><span class="o">-</span><span class="n">zfs</span> <span class="o">-</span><span class="n">l</span> <span class="n">osd</span><span class="mf">.1</span><span class="o">-</span><span class="n">cache</span> <span class="o">-</span><span class="n">s</span> <span class="mi">10</span><span class="n">G</span> <span class="n">ada2</span>
<span class="n">zpool</span> <span class="n">add</span> <span class="n">osd</span><span class="mf">.1</span> <span class="n">log</span> <span class="n">gpt</span><span class="o">/</span><span class="n">osd</span><span class="mf">.1</span><span class="o">-</span><span class="n">cache</span>
</pre></div>
</div>
</li>
<li><p>注意： <em>UFS2 不支持大量 xattribs</em></p></li>
</ul>
<section id="id2">
<h3>配置文件<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h3>
<p>As per FreeBSD default parts of extra software go into <code class="docutils literal notranslate"><span class="pre">/usr/local/</span></code>. Which
means that for <code class="docutils literal notranslate"><span class="pre">/etc/ceph.conf</span></code> the default location is
<code class="docutils literal notranslate"><span class="pre">/usr/local/etc/ceph/ceph.conf</span></code>. Smartest thing to do is to create a softlink
from <code class="docutils literal notranslate"><span class="pre">/etc/ceph</span></code> to <code class="docutils literal notranslate"><span class="pre">/usr/local/etc/ceph</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ln</span> <span class="o">-</span><span class="n">s</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">local</span><span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span>
</pre></div>
</div>
<p>A sample file is provided in <code class="docutils literal notranslate"><span class="pre">/usr/local/share/doc/ceph/sample.ceph.conf</span></code>
Note that <code class="docutils literal notranslate"><span class="pre">/usr/local/etc/ceph/ceph.conf</span></code> will be found by most tools,
linking it to <code class="docutils literal notranslate"><span class="pre">/etc/ceph/ceph.conf</span></code> will help with any scripts that are found
in extra tools, scripts, and/or discussionlists.</p>
</section>
</section>
<section id="id3">
<h2>监视器自举启动<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>自举引导一个监视器（理论上是一套 Ceph 存储集群）需要准备几件事：</p>
<ul>
<li><p><strong>Unique Identifier:</strong> The <code class="docutils literal notranslate"><span class="pre">fsid</span></code> is a unique identifier for the cluster,
and stands for File System ID from the days when the Ceph Storage Cluster was
principally for the Ceph Filesystem. Ceph now supports native interfaces,
block devices, and object storage gateway interfaces too, so <code class="docutils literal notranslate"><span class="pre">fsid</span></code> is a
bit of a misnomer.</p></li>
<li><p><strong>Cluster Name:</strong> Ceph clusters have a cluster name, which is a simple string
without spaces. The default cluster name is <code class="docutils literal notranslate"><span class="pre">ceph</span></code>, but you may specify
a different cluster name. Overriding the default cluster name is
especially useful when you are working with multiple clusters and you need to
clearly understand which cluster your are working with.</p>
<p>For example, when you run multiple clusters in a <a class="reference internal" href="../../radosgw/multisite/#multisite"><span class="std std-ref">multisite configuration</span></a>,
the cluster name (e.g., <code class="docutils literal notranslate"><span class="pre">us-west</span></code>, <code class="docutils literal notranslate"><span class="pre">us-east</span></code>) identifies the cluster for
the current CLI session. <strong>Note:</strong> To identify the cluster name on the
command line interface, specify the a Ceph configuration file with the
cluster name (e.g., <code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code>, <code class="docutils literal notranslate"><span class="pre">us-west.conf</span></code>, <code class="docutils literal notranslate"><span class="pre">us-east.conf</span></code>, etc.).
Also see CLI usage (<code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">--cluster</span> <span class="pre">{cluster-name}</span></code>).</p>
</li>
<li><p><strong>Monitor Name:</strong> Each monitor instance within a cluster has a unique name.
In common practice, the Ceph Monitor name is the host name (we recommend one
Ceph Monitor per host, and no commingling of Ceph OSD Daemons with
Ceph Monitors). You may retrieve the short hostname with <code class="docutils literal notranslate"><span class="pre">hostname</span> <span class="pre">-s</span></code>.</p></li>
<li><p><strong>Monitor Map:</strong> Bootstrapping the initial monitor(s) requires you to
generate a monitor map. The monitor map requires the <code class="docutils literal notranslate"><span class="pre">fsid</span></code>, the cluster
name (or uses the default), and at least one host name and its IP address.</p></li>
<li><p><strong>Monitor Keyring</strong>: Monitors communicate with each other via a
secret key. You must generate a keyring with a monitor secret and provide
it when bootstrapping the initial monitor(s).</p></li>
<li><p><strong>Administrator Keyring</strong>: To use the <code class="docutils literal notranslate"><span class="pre">ceph</span></code> CLI tools, you must have
a <code class="docutils literal notranslate"><span class="pre">client.admin</span></code> user. So you must generate the admin user and keyring,
and you must also add the <code class="docutils literal notranslate"><span class="pre">client.admin</span></code> user to the monitor keyring.</p></li>
</ul>
<p>The foregoing requirements do not imply the creation of a Ceph Configuration
file. However, as a best practice, we recommend creating a Ceph configuration
file and populating it with the <code class="docutils literal notranslate"><span class="pre">fsid</span></code>, the <code class="docutils literal notranslate"><span class="pre">mon</span> <span class="pre">initial</span> <span class="pre">members</span></code> and the
<code class="docutils literal notranslate"><span class="pre">mon</span> <span class="pre">host</span></code> settings.</p>
<p>You can get and set all of the monitor settings at runtime as well. However,
a Ceph Configuration file may contain only those settings that override the
default values. When you add settings to a Ceph configuration file, these
settings override the default settings. Maintaining those settings in a
Ceph configuration file makes it easier to maintain your cluster.</p>
<p>The procedure is as follows:</p>
<ol class="arabic">
<li><p>Log in to the initial monitor node(s):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="n">node1</span>
</pre></div>
</div>
</li>
<li><p>Ensure you have a directory for the Ceph configuration file. By default,
Ceph uses <code class="docutils literal notranslate"><span class="pre">/etc/ceph</span></code>. When you install <code class="docutils literal notranslate"><span class="pre">ceph</span></code>, the installer will
create the <code class="docutils literal notranslate"><span class="pre">/etc/ceph</span></code> directory automatically.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ls</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span>
</pre></div>
</div>
</li>
<li><p>Create a Ceph configuration file. By default, Ceph uses
<code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code>, where <code class="docutils literal notranslate"><span class="pre">ceph</span></code> reflects the cluster name.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">vim</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">conf</span>
</pre></div>
</div>
</li>
<li><p>Generate a unique ID (i.e., <code class="docutils literal notranslate"><span class="pre">fsid</span></code>) for your cluster.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">uuidgen</span>
</pre></div>
</div>
</li>
<li><p>Add the unique ID to your Ceph configuration file.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fsid</span> <span class="o">=</span> <span class="p">{</span><span class="n">UUID</span><span class="p">}</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fsid</span> <span class="o">=</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span>
</pre></div>
</div>
</li>
<li><p>Add the initial monitor(s) to your Ceph configuration file.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="n">initial</span> <span class="n">members</span> <span class="o">=</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}[,{</span><span class="n">hostname</span><span class="p">}]</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="n">initial</span> <span class="n">members</span> <span class="o">=</span> <span class="n">node1</span>
</pre></div>
</div>
</li>
<li><p>Add the IP address(es) of the initial monitor(s) to your Ceph configuration
file and save the file.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}[,{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}]</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="mf">192.168.0.1</span>
</pre></div>
</div>
<p><strong>Note:</strong> You may use IPv6 addresses instead of IPv4 addresses, but
you must set <code class="docutils literal notranslate"><span class="pre">ms</span> <span class="pre">bind</span> <span class="pre">ipv6</span></code> to <code class="docutils literal notranslate"><span class="pre">true</span></code>. See <a class="reference external" href="../../rados/configuration/network-config-ref">Network Configuration
Reference</a> for details about network configuration.</p>
</li>
<li><p>Create a keyring for your cluster and generate a monitor secret key.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">--</span><span class="n">create</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span> <span class="o">--</span><span class="n">gen</span><span class="o">-</span><span class="n">key</span> <span class="o">-</span><span class="n">n</span> <span class="n">mon</span><span class="o">.</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mon</span> <span class="s1">&#39;allow *&#39;</span>
</pre></div>
</div>
</li>
<li><p>生成管理员密钥环，生成一个 <code class="docutils literal notranslate"><span class="pre">client.admin</span></code> 用户，并把它加进密钥环。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">--</span><span class="n">create</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">admin</span><span class="o">.</span><span class="n">keyring</span> <span class="o">--</span><span class="n">gen</span><span class="o">-</span><span class="n">key</span> <span class="o">-</span><span class="n">n</span> <span class="n">client</span><span class="o">.</span><span class="n">admin</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mon</span> <span class="s1">&#39;allow *&#39;</span> <span class="o">--</span><span class="n">cap</span> <span class="n">osd</span> <span class="s1">&#39;allow *&#39;</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mds</span> <span class="s1">&#39;allow *&#39;</span> <span class="o">--</span><span class="n">cap</span> <span class="n">mgr</span> <span class="s1">&#39;allow *&#39;</span>
</pre></div>
</div>
</li>
<li><p>Add the <code class="docutils literal notranslate"><span class="pre">client.admin</span></code> key to the <code class="docutils literal notranslate"><span class="pre">ceph.mon.keyring</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span> <span class="o">--</span><span class="n">import</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">admin</span><span class="o">.</span><span class="n">keyring</span>
</pre></div>
</div>
</li>
<li><p>Generate a monitor map using the hostname(s), host IP address(es) and the FSID.
Save it as <code class="docutils literal notranslate"><span class="pre">/tmp/monmap</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">monmaptool</span> <span class="o">--</span><span class="n">create</span> <span class="o">--</span><span class="n">add</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}</span> <span class="o">--</span><span class="n">fsid</span> <span class="p">{</span><span class="n">uuid</span><span class="p">}</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">monmap</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">monmaptool</span> <span class="o">--</span><span class="n">create</span> <span class="o">--</span><span class="n">add</span> <span class="n">node1</span> <span class="mf">192.168.0.1</span> <span class="o">--</span><span class="n">fsid</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">monmap</span>
</pre></div>
</div>
</li>
<li><p>Create a default data directory (or directories) on the monitor host(s).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">mkdir</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mon</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="n">hostname</span><span class="p">}</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">mkdir</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mon</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="n">node1</span>
</pre></div>
</div>
<p>See <a class="reference external" href="../../rados/configuration/mon-config-ref#data">Monitor Config Reference - Data</a> for details.</p>
</li>
<li><p>Populate the monitor daemon(s) with the monitor map and keyring.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="o">-</span><span class="n">u</span> <span class="n">ceph</span> <span class="n">ceph</span><span class="o">-</span><span class="n">mon</span> <span class="p">[</span><span class="o">--</span><span class="n">cluster</span> <span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="o">--</span><span class="n">mkfs</span> <span class="o">-</span><span class="n">i</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span> <span class="o">--</span><span class="n">monmap</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">monmap</span> <span class="o">--</span><span class="n">keyring</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="o">-</span><span class="n">u</span> <span class="n">ceph</span> <span class="n">ceph</span><span class="o">-</span><span class="n">mon</span> <span class="o">--</span><span class="n">mkfs</span> <span class="o">-</span><span class="n">i</span> <span class="n">node1</span> <span class="o">--</span><span class="n">monmap</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">monmap</span> <span class="o">--</span><span class="n">keyring</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">mon</span><span class="o">.</span><span class="n">keyring</span>
</pre></div>
</div>
</li>
<li><p>Consider settings for a Ceph configuration file. Common settings include
the following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="k">global</span><span class="p">]</span>
<span class="n">fsid</span> <span class="o">=</span> <span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="nb">id</span><span class="p">}</span>
<span class="n">mon</span> <span class="n">initial</span> <span class="n">members</span> <span class="o">=</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}[,</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}]</span>
<span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}[,</span> <span class="p">{</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}]</span>
<span class="n">public</span> <span class="n">network</span> <span class="o">=</span> <span class="p">{</span><span class="n">network</span><span class="p">}[,</span> <span class="p">{</span><span class="n">network</span><span class="p">}]</span>
<span class="n">cluster</span> <span class="n">network</span> <span class="o">=</span> <span class="p">{</span><span class="n">network</span><span class="p">}[,</span> <span class="p">{</span><span class="n">network</span><span class="p">}]</span>
<span class="n">auth</span> <span class="n">cluster</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">auth</span> <span class="n">service</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">auth</span> <span class="n">client</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">osd</span> <span class="n">journal</span> <span class="n">size</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">size</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>  <span class="c1"># Write an object n times.</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="nb">min</span> <span class="n">size</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span> <span class="c1"># Allow writing n copy in a degraded state.</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">pg</span> <span class="n">num</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">pgp</span> <span class="n">num</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>
<span class="n">osd</span> <span class="n">crush</span> <span class="n">chooseleaf</span> <span class="nb">type</span> <span class="o">=</span> <span class="p">{</span><span class="n">n</span><span class="p">}</span>
</pre></div>
</div>
<p>In the foregoing example, the <code class="docutils literal notranslate"><span class="pre">[global]</span></code> section of the configuration might
look like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="k">global</span><span class="p">]</span>
<span class="n">fsid</span> <span class="o">=</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span>
<span class="n">mon</span> <span class="n">initial</span> <span class="n">members</span> <span class="o">=</span> <span class="n">node1</span>
<span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="mf">192.168.0.1</span>
<span class="n">public</span> <span class="n">network</span> <span class="o">=</span> <span class="mf">192.168.0.0</span><span class="o">/</span><span class="mi">24</span>
<span class="n">auth</span> <span class="n">cluster</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">auth</span> <span class="n">service</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">auth</span> <span class="n">client</span> <span class="n">required</span> <span class="o">=</span> <span class="n">cephx</span>
<span class="n">osd</span> <span class="n">journal</span> <span class="n">size</span> <span class="o">=</span> <span class="mi">1024</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">size</span> <span class="o">=</span> <span class="mi">3</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="nb">min</span> <span class="n">size</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">pg</span> <span class="n">num</span> <span class="o">=</span> <span class="mi">333</span>
<span class="n">osd</span> <span class="n">pool</span> <span class="n">default</span> <span class="n">pgp</span> <span class="n">num</span> <span class="o">=</span> <span class="mi">333</span>
<span class="n">osd</span> <span class="n">crush</span> <span class="n">chooseleaf</span> <span class="nb">type</span> <span class="o">=</span> <span class="mi">1</span>
</pre></div>
</div>
</li>
<li><p>Touch the <code class="docutils literal notranslate"><span class="pre">done</span></code> file.</p>
<p>Mark that the monitor is created and ready to be started:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">touch</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mon</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="n">node1</span><span class="o">/</span><span class="n">done</span>
</pre></div>
</div>
</li>
<li><p>And for FreeBSD an entry for every monitor needs to be added to the config
file. (The requirement will be removed in future releases).</p>
<p>The entry should look like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">mon</span><span class="p">]</span>
    <span class="p">[</span><span class="n">mon</span><span class="o">.</span><span class="n">node1</span><span class="p">]</span>
        <span class="n">host</span> <span class="o">=</span> <span class="n">node1</span>    <span class="c1"># this name can be resolve</span>
</pre></div>
</div>
</li>
<li><p>Start the monitor(s).</p>
<p>For FreeBSD we use the rc.d init scripts (called bsdrc in Ceph):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">service</span> <span class="n">ceph</span> <span class="n">start</span> <span class="n">start</span> <span class="n">mon</span><span class="o">.</span><span class="n">node1</span>
</pre></div>
</div>
<dl class="simple">
<dt>For this to work /etc/rc.conf also needs the entry to enable ceph::</dt><dd><p>cat ‘ceph_enable=”YES”’ &gt;&gt; /etc/rc.conf</p>
</dd>
</dl>
</li>
<li><p>Verify that Ceph created the default pools.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">lspools</span>
</pre></div>
</div>
<p>You should see output like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">0</span> <span class="n">data</span>
<span class="mi">1</span> <span class="n">metadata</span>
<span class="mi">2</span> <span class="n">rbd</span>
</pre></div>
</div>
</li>
<li><p>Verify that the monitor is running.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="o">-</span><span class="n">s</span>
</pre></div>
</div>
<p>You should see output that the monitor you started is up and running, and
you should see a health error indicating that placement groups are stuck
inactive. It should look something like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cluster</span> <span class="n">a7f64266</span><span class="o">-</span><span class="mi">0894</span><span class="o">-</span><span class="mi">4</span><span class="n">f1e</span><span class="o">-</span><span class="n">a635</span><span class="o">-</span><span class="n">d0aeaca0e993</span>
  <span class="n">health</span> <span class="n">HEALTH_ERR</span> <span class="mi">192</span> <span class="n">pgs</span> <span class="n">stuck</span> <span class="n">inactive</span><span class="p">;</span> <span class="mi">192</span> <span class="n">pgs</span> <span class="n">stuck</span> <span class="n">unclean</span><span class="p">;</span> <span class="n">no</span> <span class="n">osds</span>
  <span class="n">monmap</span> <span class="n">e1</span><span class="p">:</span> <span class="mi">1</span> <span class="n">mons</span> <span class="n">at</span> <span class="p">{</span><span class="n">node1</span><span class="o">=</span><span class="mf">192.168.0.1</span><span class="p">:</span><span class="mi">6789</span><span class="o">/</span><span class="mi">0</span><span class="p">},</span> <span class="n">election</span> <span class="n">epoch</span> <span class="mi">1</span><span class="p">,</span> <span class="n">quorum</span> <span class="mi">0</span> <span class="n">node1</span>
  <span class="n">osdmap</span> <span class="n">e1</span><span class="p">:</span> <span class="mi">0</span> <span class="n">osds</span><span class="p">:</span> <span class="mi">0</span> <span class="n">up</span><span class="p">,</span> <span class="mi">0</span> <span class="ow">in</span>
  <span class="n">pgmap</span> <span class="n">v2</span><span class="p">:</span> <span class="mi">192</span> <span class="n">pgs</span><span class="p">,</span> <span class="mi">3</span> <span class="n">pools</span><span class="p">,</span> <span class="mi">0</span> <span class="nb">bytes</span> <span class="n">data</span><span class="p">,</span> <span class="mi">0</span> <span class="n">objects</span>
     <span class="mi">0</span> <span class="n">kB</span> <span class="n">used</span><span class="p">,</span> <span class="mi">0</span> <span class="n">kB</span> <span class="o">/</span> <span class="mi">0</span> <span class="n">kB</span> <span class="n">avail</span>
     <span class="mi">192</span> <span class="n">creating</span>
</pre></div>
</div>
<p><strong>Note:</strong> Once you add OSDs and start them, the placement group health errors
should disappear. See the next section for details.</p>
</li>
</ol>
</section>
<section id="osd">
<span id="freebsd-adding-osds"></span><h2>添加 OSD<a class="headerlink" href="#osd" title="Permalink to this heading"></a></h2>
<p>你的初始监视器们正常运行后，你应该添加 OSD 。
没有足够的 OSD 来处理一个对象的多个副本
（例如 <code class="docutils literal notranslate"><span class="pre">osd</span> <span class="pre">pool</span> <span class="pre">default</span> <span class="pre">size</span> <span class="pre">=</span> <span class="pre">2</span></code> 就需要至少 2 个 OSD ），
你的集群就不能进入 <code class="docutils literal notranslate"><span class="pre">active</span> <span class="pre">+</span> <span class="pre">clean</span></code> 状态。自举引导监视器后，
集群就有了CRUSH 图，然而，这个 CRUSH 图还没有任何映射成 Ceph 节点的 Ceph OSD 守护进程。</p>
<section id="id4">
<h3>详细步骤<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h3>
<p>Without the benefit of any helper utilities, create an OSD and add it to the
cluster and CRUSH map with the following procedure. To create the first two
OSDs with the long form procedure, execute the following on <code class="docutils literal notranslate"><span class="pre">node2</span></code> and
<code class="docutils literal notranslate"><span class="pre">node3</span></code>:</p>
<ol class="arabic">
<li><p>Connect to the OSD host.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">node</span><span class="o">-</span><span class="n">name</span><span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>Generate a UUID for the OSD.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">uuidgen</span>
</pre></div>
</div>
</li>
<li><p>Create the OSD. If no UUID is given, it will be set automatically when the
OSD starts up. The following command will output the OSD number, which you
will need for subsequent steps.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">create</span> <span class="p">[{</span><span class="n">uuid</span><span class="p">}</span> <span class="p">[{</span><span class="nb">id</span><span class="p">}]]</span>
</pre></div>
</div>
</li>
<li><p>Create the default directory on your new OSD.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">new</span><span class="o">-</span><span class="n">osd</span><span class="o">-</span><span class="n">host</span><span class="p">}</span>
<span class="n">sudo</span> <span class="n">mkdir</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="n">osd</span><span class="o">-</span><span class="n">number</span><span class="p">}</span>
</pre></div>
</div>
<p>Above are the ZFS instructions to do this for FreeBSD.</p>
</li>
<li><p>If the OSD is for a drive other than the OS drive, prepare it
for use with Ceph, and mount it to the directory you just created.</p></li>
<li><p>Initialize the OSD data directory.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ssh</span> <span class="p">{</span><span class="n">new</span><span class="o">-</span><span class="n">osd</span><span class="o">-</span><span class="n">host</span><span class="p">}</span>
<span class="n">sudo</span> <span class="n">ceph</span><span class="o">-</span><span class="n">osd</span> <span class="o">-</span><span class="n">i</span> <span class="p">{</span><span class="n">osd</span><span class="o">-</span><span class="n">num</span><span class="p">}</span> <span class="o">--</span><span class="n">mkfs</span> <span class="o">--</span><span class="n">mkkey</span> <span class="o">--</span><span class="n">osd</span><span class="o">-</span><span class="n">uuid</span> <span class="p">[{</span><span class="n">uuid</span><span class="p">}]</span>
</pre></div>
</div>
<p>The directory must be empty before you can run <code class="docutils literal notranslate"><span class="pre">ceph-osd</span></code> with the
<code class="docutils literal notranslate"><span class="pre">--mkkey</span></code> option. In addition, the ceph-osd tool requires specification
of custom cluster names with the <code class="docutils literal notranslate"><span class="pre">--cluster</span></code> option.</p>
</li>
<li><p>Register the OSD authentication key. The value of <code class="docutils literal notranslate"><span class="pre">ceph</span></code> for
<code class="docutils literal notranslate"><span class="pre">ceph-{osd-num}</span></code> in the path is the <code class="docutils literal notranslate"><span class="pre">$cluster-$id</span></code>.  If your
cluster name differs from <code class="docutils literal notranslate"><span class="pre">ceph</span></code>, use your cluster name instead.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">ceph</span> <span class="n">auth</span> <span class="n">add</span> <span class="n">osd</span><span class="o">.</span><span class="p">{</span><span class="n">osd</span><span class="o">-</span><span class="n">num</span><span class="p">}</span> <span class="n">osd</span> <span class="s1">&#39;allow *&#39;</span> <span class="n">mon</span> <span class="s1">&#39;allow profile osd&#39;</span> <span class="o">-</span><span class="n">i</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="n">osd</span><span class="o">-</span><span class="n">num</span><span class="p">}</span><span class="o">/</span><span class="n">keyring</span>
</pre></div>
</div>
</li>
<li><p>Add your Ceph Node to the CRUSH map.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="p">[</span><span class="o">--</span><span class="n">cluster</span> <span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="n">osd</span> <span class="n">crush</span> <span class="n">add</span><span class="o">-</span><span class="n">bucket</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span> <span class="n">host</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">crush</span> <span class="n">add</span><span class="o">-</span><span class="n">bucket</span> <span class="n">node1</span> <span class="n">host</span>
</pre></div>
</div>
</li>
<li><p>Place the Ceph Node under the root <code class="docutils literal notranslate"><span class="pre">default</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">crush</span> <span class="n">move</span> <span class="n">node1</span> <span class="n">root</span><span class="o">=</span><span class="n">default</span>
</pre></div>
</div>
</li>
<li><p>Add the OSD to the CRUSH map so that it can begin receiving data. You may
also decompile the CRUSH map, add the OSD to the device list, add the host as a
bucket (if it’s not already in the CRUSH map), add the device as an item in the
host, assign it a weight, recompile it and set it.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="p">[</span><span class="o">--</span><span class="n">cluster</span> <span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}]</span> <span class="n">osd</span> <span class="n">crush</span> <span class="n">add</span> <span class="p">{</span><span class="nb">id</span><span class="o">-</span><span class="ow">or</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="p">{</span><span class="n">weight</span><span class="p">}</span> <span class="p">[{</span><span class="n">bucket</span><span class="o">-</span><span class="nb">type</span><span class="p">}</span><span class="o">=</span><span class="p">{</span><span class="n">bucket</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="o">...</span><span class="p">]</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">crush</span> <span class="n">add</span> <span class="n">osd</span><span class="mf">.0</span> <span class="mf">1.0</span> <span class="n">host</span><span class="o">=</span><span class="n">node1</span>
</pre></div>
</div>
</li>
<li><p>After you add an OSD to Ceph, the OSD is in your configuration. However,
it is not yet running. The OSD is <code class="docutils literal notranslate"><span class="pre">down</span></code> and <code class="docutils literal notranslate"><span class="pre">in</span></code>. You must start
your new OSD before it can begin receiving data.</p>
<p>For FreeBSD using rc.d init.</p>
<p>After adding the OSD to <code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">service</span> <span class="n">ceph</span> <span class="n">start</span> <span class="n">osd</span><span class="o">.</span><span class="p">{</span><span class="n">osd</span><span class="o">-</span><span class="n">num</span><span class="p">}</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">service</span> <span class="n">ceph</span> <span class="n">start</span> <span class="n">osd</span><span class="mf">.0</span>
<span class="n">sudo</span> <span class="n">service</span> <span class="n">ceph</span> <span class="n">start</span> <span class="n">osd</span><span class="mf">.1</span>
</pre></div>
</div>
<p>In this case, to allow the start of the daemon at each reboot you
must create an empty file like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">touch</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="n">osd</span><span class="o">-</span><span class="n">num</span><span class="p">}</span><span class="o">/</span><span class="n">bsdrc</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">touch</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="mi">0</span><span class="o">/</span><span class="n">bsdrc</span>
<span class="n">sudo</span> <span class="n">touch</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">osd</span><span class="o">/</span><span class="n">ceph</span><span class="o">-</span><span class="mi">1</span><span class="o">/</span><span class="n">bsdrc</span>
</pre></div>
</div>
<p>Once you start your OSD, it is <code class="docutils literal notranslate"><span class="pre">up</span></code> and <code class="docutils literal notranslate"><span class="pre">in</span></code>.</p>
</li>
</ol>
</section>
</section>
<section id="mds">
<h2>添加 MDS<a class="headerlink" href="#mds" title="Permalink to this heading"></a></h2>
<p>In the below instructions, <code class="docutils literal notranslate"><span class="pre">{id}</span></code> is an arbitrary name, such as the hostname of the machine.</p>
<ol class="arabic">
<li><p>Create the mds data directory.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mkdir</span> <span class="o">-</span><span class="n">p</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mds</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>Create a keyring.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">authtool</span> <span class="o">--</span><span class="n">create</span><span class="o">-</span><span class="n">keyring</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mds</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span><span class="o">/</span><span class="n">keyring</span> <span class="o">--</span><span class="n">gen</span><span class="o">-</span><span class="n">key</span> <span class="o">-</span><span class="n">n</span> <span class="n">mds</span><span class="o">.</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>Import the keyring and set caps.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">auth</span> <span class="n">add</span> <span class="n">mds</span><span class="o">.</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span> <span class="n">osd</span> <span class="s2">&quot;allow rwx&quot;</span> <span class="n">mds</span> <span class="s2">&quot;allow *&quot;</span> <span class="n">mon</span> <span class="s2">&quot;allow profile mds&quot;</span> <span class="o">-</span><span class="n">i</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">mds</span><span class="o">/</span><span class="p">{</span><span class="n">cluster</span><span class="p">}</span><span class="o">-</span><span class="p">{</span><span class="nb">id</span><span class="p">}</span><span class="o">/</span><span class="n">keyring</span>
</pre></div>
</div>
</li>
<li><p>Add to ceph.conf.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">mds</span><span class="o">.</span><span class="p">{</span><span class="nb">id</span><span class="p">}]</span>
<span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="nb">id</span><span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>Start the daemon the manual way.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">mds</span> <span class="o">--</span><span class="n">cluster</span> <span class="p">{</span><span class="n">cluster</span><span class="o">-</span><span class="n">name</span><span class="p">}</span> <span class="o">-</span><span class="n">i</span> <span class="p">{</span><span class="nb">id</span><span class="p">}</span> <span class="o">-</span><span class="n">m</span> <span class="p">{</span><span class="n">mon</span><span class="o">-</span><span class="n">hostname</span><span class="p">}:{</span><span class="n">mon</span><span class="o">-</span><span class="n">port</span><span class="p">}</span> <span class="p">[</span><span class="o">-</span><span class="n">f</span><span class="p">]</span>
</pre></div>
</div>
</li>
<li><p>Start the daemon the right way (using ceph.conf entry).:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">service</span> <span class="n">ceph</span> <span class="n">start</span>
</pre></div>
</div>
</li>
<li><p>If starting the daemon fails with this error:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mds</span><span class="o">.-</span><span class="mf">1.0</span> <span class="n">ERROR</span><span class="p">:</span> <span class="n">failed</span> <span class="n">to</span> <span class="n">authenticate</span><span class="p">:</span> <span class="p">(</span><span class="mi">22</span><span class="p">)</span> <span class="n">Invalid</span> <span class="n">argument</span>
</pre></div>
</div>
<p>Then make sure you do not have a keyring set in ceph.conf in the global section; move it to the client section; or add a keyring setting specific to this mds daemon. And verify that you see the same key in the mds data directory and <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">auth</span> <span class="pre">get</span> <span class="pre">mds.{id}</span></code> output.</p>
</li>
<li><p>Now you are ready to <a class="reference external" href="../../cephfs/createfs">create a Ceph filesystem</a>.</p></li>
</ol>
</section>
<section id="id5">
<h2>总结<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h2>
<p>把监视器和两个 OSD 配置好并开始运行后，你可以用下列命令看归置组的互联情况：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="o">-</span><span class="n">w</span>
</pre></div>
</div>
<p>用下列命令查看 OSD 树：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">tree</span>
</pre></div>
</div>
<p>You should see output that looks something like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># id    weight    type name    up/down    reweight</span>
<span class="o">-</span><span class="mi">1</span>      <span class="mi">2</span>       <span class="n">root</span> <span class="n">default</span>
<span class="o">-</span><span class="mi">2</span>      <span class="mi">2</span>            <span class="n">host</span> <span class="n">node1</span>
<span class="mi">0</span>       <span class="mi">1</span>                <span class="n">osd</span><span class="mf">.0</span>    <span class="n">up</span>    <span class="mi">1</span>
<span class="o">-</span><span class="mi">3</span>      <span class="mi">1</span>            <span class="n">host</span> <span class="n">node2</span>
<span class="mi">1</span>       <span class="mi">1</span>                <span class="n">osd</span><span class="mf">.1</span>    <span class="n">up</span>    <span class="mi">1</span>
</pre></div>
</div>
<p>To add (or remove) additional monitors, see <a class="reference external" href="../../rados/operations/add-or-rm-mons">Add/Remove Monitors</a>.
To add (or remove) additional Ceph OSD Daemons, see <a class="reference external" href="../../rados/operations/add-or-rm-osds">Add/Remove OSDs</a>.</p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../manual-deployment/" class="btn btn-neutral float-left" title="手动部署" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../../cephadm/" class="btn btn-neutral float-right" title="Cephadm" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>